<?php
declare(strict_types=1);

namespace LowCode\Naive;

use LowCode\Naive;
use LowCode\Support\JsExp;
use LowCode\Traits\Props\HasDefaultValue;
use LowCode\Traits\Props\HasDisabled;
use LowCode\Traits\Props\HasSize;
use LowCode\Traits\Props\HasValueModel;

/**
 * Checkbox组件
 * @method static static make() Checkbox组件
 */
class Checkbox extends Naive
{

    use HasDisabled, HasSize, HasValueModel, HasDefaultValue;

    /**
     */
    public function __construct()
    {
        parent::__construct();

    }

    /**
     * 发生变化时触发的回调方法
     * @param string $event (value: boolean) => void
     * @param string|null $id
     * @param array $modifiers
     * @return $this
     */
    public function onChange(string $event = "(value) => {}", string $id = null, array $modifiers = []): static
    {
        return $this->event('change', jsFn($event, $id), $modifiers);
    }

    /**
     * 设置组件选择状态
     * @param bool|JsExp $bool
     * @return $this
     */
    public function checked(bool|JsExp $bool = false): static
    {
        return $this->prop('checked', $bool);
    }

    /**
     * 设置组件选择状态
     * @param string $value
     * @param string|null $id
     * @param array $options
     * @return $this
     */
    public function vModelChecked(string $value, string $id = null, array $options = []): static
    {
        return $this->vModelArg("checked", $value, $id, $options);
    }
}
